package yxy.game.pm2.module.camptower;

import yxy.game.pm2.bean.Currency;
import yxy.game.pm2.bean.mq.CCReason;
import yxy.game.pm2.module.CurrencyHandle;
import yxy.game.pm2.module.battle.ISettlement;

import java.util.ArrayList;
import java.util.Collection;

/**
 * 阵营塔结算
 *
 * @ClassName SettlementCampTower
 * @Author jingtao-zheng
 * @Date 2022/8/2 11:28
 * @Version 1.0
 **/
public class SettlementCampTower implements ISettlement {
// bean===========================================================================

    private String playerCode;
    private ArrayList<Currency> rewards = new ArrayList<>();
    private int floor;
    private int type;
    private int starnum;//星星数

    public String getPlayerCode() {
        return playerCode;
    }

    public void setPlayerCode(String playerCode) {
        this.playerCode = playerCode;
    }

    public ArrayList<Currency> getRewards() {
        return rewards;
    }

    public void setRewards(ArrayList<Currency> rewards) {
        this.rewards = rewards;
    }

    public int getFloor() {
        return floor;
    }

    public void setFloor(int floor) {
        this.floor = floor;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getStarnum() {
        return starnum;
    }

    public void setStarnum(int starnum) {
        this.starnum = starnum;
    }
    // func===========================================================================

    @Override
    public void settle() {
        new CurrencyHandle().addCurrency(playerCode, CCReason.阵营塔, getRewards());
        //记录排行榜
        new CampTowerHandle().nextFloor(getPlayerCode(), getFloor(), getType(), getStarnum());
    }

    @Override
    public Collection<Currency> reward() {
        return getRewards();
    }

    static public SettlementCampTower create(String playerCode, int floor, boolean first, int type) {
        SettlementCampTower settlement = new SettlementCampTower();
        try {
            settlement.setPlayerCode(playerCode);
            settlement.setFloor(floor);
            settlement.setType(type);
            settlement.setRewards(new ArrayList<>(CampTowerHandle.floorRewards(floor, first, type)));
            //假星星数代替
            settlement.setStarnum(0);
            return settlement;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
